package Utils;

import java.util.Map;

/**
 * @author jianjun
 * @Describe
 * @creat 2021-12-22-20:02
 */
public class WebUtils {
    public static <T> T copyToBean(Map value , T bean){
        try {
            Map<String, String[]> parameterMap = value;
            for (Map.Entry<String, String[]> entry : parameterMap.entrySet()){
                org.apache.commons.beanutils.BeanUtils.copyProperty(bean,entry.getKey(),entry.getValue());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bean;
    }

    public static int parseInt(String str, Integer defaultValue){
        if (str == null){
            return defaultValue;
        }
        return Integer.parseInt(str);
    }
}
